package huixue.cn.com.rxapp.rx.service;

import android.app.Service;
import android.content.Intent;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.Messenger;
import android.support.annotation.Nullable;

import huixue.cn.com.rxapp.util.LogUtils;

/**
 * Created by gongdongyang 2019/8/8
 * Describe:
 */
public class MessengerService extends Service {

    private Messenger messenger = new Messenger(new Handler(){
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            LogUtils.e("MessengerService","arg1==>:"+msg.arg1+"");
            Message msg1 = new Message();
            msg1.arg1 = msg.arg1 + msg.arg2;
            try {
                msg.replyTo.send(msg1);
            }catch (Exception e){

            }
        }
    });

    public MessengerService() {

    }


    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        return messenger.getBinder();
    }
}
